package com.hirelinfo.dao.faculty;



import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;



@Repository
public class HibernateDao {

	@Autowired
	private SessionFactory sessionFactory;
   
	public void insertNewRow(Object entityToSave){
		Session session=sessionFactory.openSession();
		Transaction transaction=session.beginTransaction();
		session.save(entityToSave);
		transaction.commit();
		session.close();
		
	}
	
	
	
	public void updateCurrentRow(Class entityToUpdate){
		
		
		
	}

	
	
	
	public List loadAllRowsForCriteria(DetachedCriteria criteria){
		
	 Session session=sessionFactory.getCurrentSession();
	List list=   criteria.getExecutableCriteria(session).list();
		
		return list;
		
	}
	
	
	
	
	

}
